/*
 *  Date.cpp
 *  Calendar
 *
 *  Created by Fredrik Gustafsson on 9/27/10.
 *  Copyright 2010 Kungliga Tekniska Högskolan. All rights reserved.
 *
 */

#include "date.h"

using namespace lab2;


Date::Date() {
}

Date& Date::operator=(const Date& d) {
	this->set_date_from_base(d.mod_julian_day());
	return *this;
}

bool Date::operator==(const Date& d) const {
	return this->mod_julian_day() == d.mod_julian_day();
}
bool Date::operator!=(const Date& d) const {
	return this->mod_julian_day() != d.mod_julian_day();
}
bool Date::operator<(const Date& d) const {
	return this->mod_julian_day() < d.mod_julian_day();
}
bool Date::operator<=(const Date& d) const {
	return this->mod_julian_day() <= d.mod_julian_day();
}
bool Date::operator>(const Date& d) const {
	return this->mod_julian_day() > d.mod_julian_day();
}
bool Date::operator>=(const Date& d) const {
	return this->mod_julian_day() >= d.mod_julian_day();
}

Date& Date::operator++() {
	this->set_date_from_base(this->mod_julian_day()+1);
	return *this;
}

Date& Date::operator--() {
	this->set_date_from_base(this->mod_julian_day()-1);
	return *this;
}

Date& Date::operator+=(const int n) {
	this->set_date_from_base(this->mod_julian_day()+n);
	return *this;
}

Date& Date::operator-=(const int n) {
	this->set_date_from_base(this->mod_julian_day()-n);
	return *this;
}

int Date::operator-(const Date& d) const {
	return (this->mod_julian_day() - d.mod_julian_day());
}

std::ostream& operator<<(std::ostream& os, const Date& d) {
	d.print(os);
	return os;
}
